package com.ruoyi.zuzhi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zuzhi.domain.PositionCategory;
import com.ruoyi.zuzhi.service.IPositionCategoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 职位类别Controller
 * 
 * @author lgy
 * @date 2025-05-30
 */
@RestController
@RequestMapping("/positionCategory/positionCategory")
public class PositionCategoryController extends BaseController
{
    @Autowired
    private IPositionCategoryService positionCategoryService;

    /**
     * 查询职位类别列表
     */
    @PreAuthorize("@ss.hasPermi('positionCategory:positionCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(PositionCategory positionCategory)
    {
        startPage();
        List<PositionCategory> list = positionCategoryService.selectPositionCategoryList(positionCategory);
        return getDataTable(list);
    }

    /**
     * 导出职位类别列表
     */
    @PreAuthorize("@ss.hasPermi('positionCategory:positionCategory:export')")
    @Log(title = "职位类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PositionCategory positionCategory)
    {
        List<PositionCategory> list = positionCategoryService.selectPositionCategoryList(positionCategory);
        ExcelUtil<PositionCategory> util = new ExcelUtil<PositionCategory>(PositionCategory.class);
        util.exportExcel(response, list, "职位类别数据");
    }

    /**
     * 获取职位类别详细信息
     */
    @PreAuthorize("@ss.hasPermi('positionCategory:positionCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(positionCategoryService.selectPositionCategoryById(id));
    }

    /**
     * 新增职位类别
     */
    @PreAuthorize("@ss.hasPermi('positionCategory:positionCategory:add')")
    @Log(title = "职位类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PositionCategory positionCategory)
    {
        return toAjax(positionCategoryService.insertPositionCategory(positionCategory));
    }

    /**
     * 修改职位类别
     */
    @PreAuthorize("@ss.hasPermi('positionCategory:positionCategory:edit')")
    @Log(title = "职位类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PositionCategory positionCategory)
    {
        return toAjax(positionCategoryService.updatePositionCategory(positionCategory));
    }

    /**
     * 删除职位类别
     */
    @PreAuthorize("@ss.hasPermi('positionCategory:positionCategory:remove')")
    @Log(title = "职位类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(positionCategoryService.deletePositionCategoryByIds(ids));
    }
}
